import React, { Component } from 'react'
import { Button,Icon } from 'antd'

export default class detail extends Component {
  constructor() {
    super()
    this.state = {
      info: {},
      flag: true,
      img: ''
    }
  }
  componentWillMount() {
    this.getInfo()
  }
  render() {
    return (
      <div>
        <Button type="primary" onClick={()=>this.goBack()}>
          <Icon type="left" />返回
        </Button>
        <div style={ {textAlign:'center'} }>
          <img src={ this.state.img  }/>
          <h2>{this.state.info.title}</h2>
        </div>
        <p>
          {this.state.info.summary}
        </p>
      </div>
    )
  }
  getInfo = async () => {
    let result = await this.$http(`${this.baseURL}/v2/movie/subject/${this.props.match.params.id}`)
    let value = await result.json()
    this.setState({
      info: value,
      img: value.images.small 
    })
  }

  goBack = () => {
    this.props.history.go(-1)
  }
}
